package luj.tool.jnproxyan.proxy.admin.http;

import luj.tool.jnproxyan.proxy.admin.AdminHttpMeta;
import luj.tool.jnproxyan.proxy.admin.AdminHttpModule;

public class HttpPathResolver {

  public HttpPathResolver(AdminHttpMeta meta) {
    _meta = meta;
  }

  public String resolve() {
    AdminHttpModule cursor = _meta.module();
    StringBuilder parent = new StringBuilder(128);

    while (cursor != null) {
      parent.insert(0, cursor.path());
      cursor = cursor.parent();
    }

    return parent.append(_meta.path()).toString();
  }

  private final AdminHttpMeta _meta;
}
